//
//  View+Tag.swift
//  BasicTools
//
//  Created by S JZ on 2025/5/28.
//

import SwiftUI

@available(macOS 10.15, *)
struct TextTag: ViewModifier {
    var cornerRadius: CGFloat = 0
    var borderColor: Color = Color.clear
    var borderWidth: CGFloat = 0
    var backgroundColor: Color = .clear
    var insets: EdgeInsets = EdgeInsets()
    
    init(cornerRadius: CGFloat, borderColor: Color, borderWidth: CGFloat, backgroundColor: Color, insets: EdgeInsets) {
        self.cornerRadius = cornerRadius
        self.borderColor = borderColor
        self.borderWidth = borderWidth
        self.backgroundColor = backgroundColor
        self.insets = insets
    }
    
    func body(content: Content) -> some View {
        content
            .padding(insets)
            .bt.viewBorder(cornerRadius: cornerRadius, borderColor: borderColor, borderWidth: borderWidth, backgroundColor: backgroundColor)
    }
}

extension BasicWrapper where Base == Text {
    public func textTag(cornerRadius: CGFloat = 0,
                        borderColor: Color = .clear,
                        borderWidth: CGFloat = 0,
                        backgroundColor: Color = .clear,
                        insets: EdgeInsets = EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)) -> some View {
        
        base.modifier(TextTag(cornerRadius: cornerRadius,
                              borderColor: borderColor,
                              borderWidth: borderWidth,
                              backgroundColor: backgroundColor,
                              insets: insets))
    }
}



